<template>
  <div class="app-container">
    <div v-show="type == 0 || type == 2">
      <el-row>
        <el-col :span="24">
          <el-form
            v-show="showSearch"
            ref="queryForm"
            :inline="true"
            :model="queryParams"
            label-width="60px"
            size="mini"
          >
            <div class="search-row" style="margin-left: 15px">
              <el-form-item label="机构名称" prop="enterpriseName" size="mini">
                <el-input
                  v-model="queryParams.enterpriseName"
                  clearable
                  placeholder="请输入机构名称"
                  @keyup.enter.native="handleQuery"
                />
              </el-form-item>
              <el-form-item label="采购人员" prop="procurementPersonnel" size="mini">
                <el-input
                  v-model="queryParams.procurementPersonnel"
                  clearable
                  placeholder="请输入采购人员"
                  @keyup.enter.native="handleQuery"
                />
              </el-form-item>
              <el-form-item label="到期时间">
                <el-date-picker
                  v-model="dateRange"
                  end-placeholder="结束日期"
                  range-separator="-"
                  start-placeholder="开始日期"
                  style="width: 240px"
                  type="daterange"
                  value-format="yyyy-MM-dd"
                ></el-date-picker>
              </el-form-item>
              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  size="mini"
                  style="margin-top: 3rem"
                  type="primary"
                  @click="handleQuery"
                  >搜索
                </el-button>
                <el-button
                  icon="el-icon-refresh"
                  size="mini"
                  @click="resetQuery"
                  >重置
                </el-button>
              </el-form-item>
            </div>
            <div class="search-row">
              <el-form-item
                label="机构类别"
                label-width="75px"
                prop="supplierType"
                size="mini"
              >
                <div class="manager-tags">
                  <span
                    v-for="dict in dict.type.supplier_type"
                    :key="dict.value"
                    :class="[
                      'manager-tag',
                      queryParams.supplierType === dict.value ? 'active' : '',
                    ]"
                    @click="handleManagerSelect(dict)"
                  >
                    {{ dict.label }}
                  </span>
                </div>
              </el-form-item>
            </div>
          </el-form>

          <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
              <el-button
                v-if="this.$store.state.user.info.companyType != '0'"
                icon="el-icon-plus"
                plain
                size="mini"
                type="primary"
                @click="handleAdd"
                >新增
              </el-button>
            </el-col>
            <el-col :span="1.5">
              <el-button
                icon="el-icon-download"
                plain
                size="mini"
                type="warning"
                @click="handleExport"
                >导出
              </el-button>
            </el-col>
            <right-toolbar
              :columns="columns"
              :showSearch.sync="showSearch"
              @queryTable="getList"
            ></right-toolbar>
          </el-row>
          <div style="width: 100%;height: 90vh;overflow:auto; margin-bottom: 30%;padding-bottom: 18%;position: relative;">
          <el-table
            size="mini"
            height="500"
            :row-style="{ height: '30px' }"
            border
            :cell-style="{ padding: '0px' }"
            ref="table"
            v-loading="loading"
            :class="{ 'no-multiple': markAs != null }"
            :data="infoList"
            :header-cell-style="{ 'text-align': 'center' }"
            :row-class-name="tableRowClassName"
            highlight-current-row
            @selection-change="handleSelectionChange"
          >
            <el-table-column
              type="selection"
              width="40"
              align="center"
            />
            <el-table-column
              :index="indexMethod"
              :show-overflow-tooltip="true"
              align="center"
              label="序"
              prop="index"
              type="index"
              width="40"
            ></el-table-column>
            <el-table-column
              v-if="columns[0].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="创建时间"
              prop="creationTime"
              width="100"
              sortable
            />
            <el-table-column
              v-if="columns[1].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="开发人"
              width="70"
              prop="creationNickName"
            />
            <el-table-column
              :show-overflow-tooltip="true"
              align="center"
              label="采购人"
              width="70"
              prop="procurementPersonnel"
            />
            <el-table-column
              v-if="columns[2].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="机构类别"
              prop="supplierType"
            >
              <template slot-scope="scope">
                <dict-tag
                  :options="dict.type.supplier_type"
                  :value="scope.row.supplierType"
                />
              </template>
            </el-table-column>
            <el-table-column
              v-if="columns[3].visible"
              :show-overflow-tooltip="true"
              align="left"
              label="机构名称"
              prop="enterpriseName"
              width="240"
            />
            <el-table-column
              v-if="columns[4].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="行政区域"
              prop="areaName"
              width="90"
            />
            <el-table-column
              v-if="columns[5].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="联系人"
              prop="contacts"
              width="60"
            />
            <el-table-column
              v-if="columns[6].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="联系人职务"
              prop="position"
              width="100"
            />
            <el-table-column
              v-if="columns[7].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="联系电话"
              prop="telephone"
              width="100"
            />
            <el-table-column
              v-if="columns[8].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="签约时间"
              prop="signTime"
              sortable
              width="100"
            >
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.signTime, "{y}-{m}-{d}") }}</span>
              </template>
            </el-table-column>
            <el-table-column
              v-if="columns[9].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="到期时间"
              prop="endTime"
              sortable
              width="100"
            >
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.endTime, "{y}-{m}-{d}") }}</span>
              </template>
            </el-table-column>
            <el-table-column
              v-if="columns[10].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="采购金额"
              prop="PurchaseAmount"
              width="100"
            />
            <el-table-column
              v-if="columns[11].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="注册状态"
              prop="registerStatus"
              width="80"
            >
              <template slot-scope="scope">
                <el-tag
                  :type="scope.row.registerStatus === 1 ? 'success' : 'danger'"
                  size="mini"
                >
                  {{ scope.row.registerStatus === 1 ? "已注册" : "未注册" }}
                </el-tag>
              </template>
            </el-table-column>
            <el-table-column
              v-if="columns[12].visible"
              :show-overflow-tooltip="true"
              align="center"
              label="最新进展"
              prop="latestDevelopments"
              width="160"
            />
            <el-table-column
              v-if="markAs == null"
              align="center"
              class-name="small-padding fixed-width"
              label="操作"
              fixed="right"
              width="85"
            >
              <template slot-scope="scope">
                <el-button
                  icon="el-icon-edit"
                  size="mini"
                  type="text"
                  @click="handleUpdate(scope.row, scope.$index + 1)"
                  title="编辑"
                ></el-button>
                <el-button
                  @click.stop="handleViewEnterprise(scope.row, scope.$index + 1)"
                  size="mini"
                  type="text"
                  icon="el-icon-view"
                  title="查看"
                ></el-button>
                <el-button
                  icon="el-icon-delete"
                  size="mini"
                  type="text"
                  @click="handleDelete(scope.row)"
                  title="删除"
                ></el-button>
              </template>
            </el-table-column>
          </el-table>

          <pagination
            v-show="total > 0"
            :limit.sync="queryParams.pageSize"
            :page.sync="queryParams.pageNum"
            :total="total"
            @pagination="getList"
          />
          </div>
        </el-col>
      </el-row>
      <!-- 图片预览 -->
      <el-dialog :visible.sync="dialogVisible" append-to-body>
        <img :src="dialogImageUrl" alt="" width="100%" />
      </el-dialog>
      <!-- pdf预览 -->
      <el-dialog :visible.sync="dialogVisiblePdf" append-to-body>
        <pdf
          v-for="item in pageTotal"
          :key="item"
          :page="item"
          :src="pdfUrl"
        ></pdf>
      </el-dialog>
      <el-dialog
        :title="titleClass"
        :visible.sync="openMainClass"
        append-to-body
        width="500px"
      >
        <el-form ref="formClass" :inline="true" :model="formClass">
          <el-form-item
            label="主分类"
            label-width="80px"
            prop="classificationId"
          >
            <treeselect
              v-model="formClass.classificationId"
              :options="optionData"
              placeholder="请选择主分类"
              style="width: 358.5px"
            />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitClassForm()">确 定</el-button>
          <el-button @click="cancelClass">关 闭</el-button>
        </div>
      </el-dialog>
      <el-row>
        <div v-if="open">
          <el-row>
            <el-col :span="24">
              <Operate
                :id="id"
                ref="operateref"
                :classId="classId"
                :newMarkAs="newMarkAs"
                :obj="obj"
                :opt="opt"
                @change="close"
              ></Operate>
            </el-col>
          </el-row>
        </div>
      </el-row>
    </div>
    <div v-if="type == 1">
      <Operate
        :id="id"
        ref="operateref"
        :classId="classId"
        :enterpriseName="enterpriseName"
        :enterpriseNo="total"
        :index="index"
        :initiationId="initiationId"
        :opt="edit"
        :receiverId="receiverId"
        :supplierId="supplierId"
        :tabId="tabId"
        @change="close"
      >
      </Operate>
    </div>
  </div>
</template>

<script>
import { delInfo, listInfo } from "@/api/supplier/supplier";
import { listArea } from "@/api/area/area";
import MainType from "@/components/MainType/index";
import { getToken } from "../../utils/auth";
import Operate from "./operate.vue";
import { listType } from "@/api/maintype/type";
import Treeselect from "@riophae/vue-treeselect";
import pdf from "vue-pdf";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import Template from "../membertemplate/index.vue";

export default {
  name: "Supplier",
  props: {
    markAs: {
      type: String,
      default: null,
    },
    enterprise: {
      type: String,
      default: null,
    },
    //选择企业的时候不能展示树节点的,同样，人员管理选择企业的时候，其他标签页不展示操作按钮
    isTree: {
      type: Boolean,
      default: true,
    },
    //判断是否是通过活动培训管理/问卷调查管理 传过来的，是的话允许多选
    train: {
      type: Boolean,
      default: false,
    },
    //判断是否是通过人员管理或者其他客户管理下面调用的，只是单纯的选择客户或者企业
    isEnterprise: {
      type: Boolean,
      default: false,
    },
  },
  components: { Template, MainType, Operate, Treeselect, pdf },
  dicts: [
    "customer_industry_serve",
    "customer_industry_garden",
    "sys_org_type",
    "sys_normal_disable",
    "enterprise_nature",
    "enterprise_source",
    "customer_industry",
    "enterprise_status",
    "supplier_type",
    "customer_industry_serve",
  ],
  data() {
    return {
      dateRange: [],
      options: null,
      initiationId: null,
      receiverId: null,
      supplierId: null,
      isMarkas: false,
      totalDept: 0,
      isAdmin: true,
      toAdmin: false,
      totalLog: 0,
      totalLogDetail: 0,
      listLog: [],
      listLogDetail: [],
      // 查询参数
      queryParamsLog: {
        pageNum: 1,
        pageSize: 15,
        shareEnterpriseName: null,
        pushId: null,
      },
      openPushClass: false,
      openLogDeailClass: false,
      //pdf预览
      dialogImageUrl: "",
      dialogImageUrlPdf: "",
      pageTotal: null,
      dialogVisible: false,
      dialogVisiblePdf: false,
      refreshKey: 0,
      typeCode: "enterprise",
      formClass: {},
      openMainClass: false,
      titleClass: "修改主分类",
      titlePushClass: "资源共享",
      titleLogDeailClass: "共享日志详情",
      titleDeptClass: "选择接收企业",
      openDeptClass: false,
      optionData: null,
      userType: "1",
      sign: "1",
      // 遮罩层
      loading: true,
      loadingPrivate: true,
      // 选中数组
      ids: [],
      shareIds: [],
      shareNames: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      tabId: null,
      totalPrivate: 0,
      // 企业信息表格数据
      infoList: [],
      infoPrivateList: [],
      classId: null,
      //导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        newMarkAs: null,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url:
          process.env.VUE_APP_BASE_API +
          "/enterprise/info/importData?markAs=" +
          this.$route.query.markAs +
          "",
      },
      // 列信息
      columns: [
        { key: 0, label: `创建时间`, visible: true },
        { key: 1, label: `创建人`, visible: true },
        { key: 2, label: `机构类别`, visible: true },
        { key: 3, label: `机构名称`, visible: true },
        { key: 4, label: `行政区域`, visible: true },
        { key: 5, label: `联系人`, visible: true },
        { key: 6, label: `联系人职务`, visible: true },
        { key: 7, label: `联系电话`, visible: true },
        { key: 8, label: `签约时间`, visible: true },
        { key: 9, label: `到期时间`, visible: true },
        { key: 10, label: `采购金额`, visible: true },
        { key: 11, label: `注册状态`, visible: true },
        { key: 12, label: `最新进展`, visible: true },
      ],

      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      selectionList: [],
      titleName: "供应商基本信息",
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 15,
        enterpriseName: null,
        enterpriseSource: null,
        enterpriseAbbreviation: null,
        administrativeArea: null,
        legalRepresentative: null,
        establishmentDate: null,
        contractAmount: null,
        procurementPersonnel:null,
        supplierType: null,
        enterpriseLabel: null,
        registeredCapital: null,
        industry: null,
        industryType: null,
        contacts: null,
        telephone: null,
        bankName: null,
        taxId: null,
        developmentId: null,
        transactionId: null,
        developmentManager: null,
        businessManager: null,
        enterpriseAddress: null,
        businessScope: null,
        enterpriseNature: null,
        markAs: null,
        belongTo: null,

        classificationId: null,
      },
      queryParamsPrivate: {
        pageNum: 1,
        pageSize: 15,
        enterpriseName: null,
        enterpriseSource: null,
        enterpriseAbbreviation: null,
        administrativeArea: null,
        legalRepresentative: null,
        establishmentDate: null,
        contractAmount: null,
        enterpriseLabel: null,
        registeredCapital: null,
        industry: null,
        industryType: null,
        contacts: null,
        telephone: null,
        bankName: null,
        taxId: null,
        developmentId: null,
        transactionId: null,
        developmentManager: null,
        businessManager: null,
        enterpriseAddress: null,
        businessScope: null,
        enterpriseNature: null,
        markAs: null,
        belongTo: null,
        classificationId: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        enterpriseName: [
          { required: true, message: "机构名称不能为空", trigger: "blur" },
        ],
      },
      type: 0,
      opt: "add",
      id: "",
      enterpriseName: null,
      obj: null,
      index: null,
      edit: "edit",
      userNewId: null,
      activeName: "first",
      activeNameShare: "first",
      selectionPushList: [],
      queryParamsLogDetail: {
        pageNum: 1,
        pageSize: 15,
        logId: null,
        shareEnterpriseName: null,
        pushName: null,
        pushTime: null,
      },
      isMainTree: false,
      deptList: [],
      // 查询参数
      queryParamsDept: {
        pageNum: 1,
        pageSize: 15,
        deptName: undefined,
        companyType: undefined,
        status: undefined,
      },
      receiveEnterpriseId: null,
      receiveEnterpriseName: null,
    };
  },
  created() {
    this.userId = this.$store.state.user.name;
    this.getList();
    this.listType();
    this.area();
  },
  methods: {
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "supplier/info/export",
        {
          ...this.queryParams,
        },
        this.titleName + "_" + new Date().getTime() + ".xlsx"
      );
    },
    handleRadioChange() {
      this.queryParams.industry = "";
    },
    area() {
      listArea({}).then(response => {
        this.options = response.data;
      });
    },
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.areaId,
        label: node.areaName,
        isDisabled: false,
        children: node.list && node.list.length > 0 ? node.list : 0,
      };
    },
    formatterNo(row, cellValue, index) {
      var number = "";
      if (row.enterpriseNo < 10) {
        number = "GYS000" + row.enterpriseNo;
      }
      if (row.enterpriseNo > 10 && row.enterpriseNo < 99) {
        number = "GYS00" + row.enterpriseNo;
      }
      if (row.enterpriseNo > 100 && row.enterpriseNo < 999) {
        row.enterpriseNo = "GYS0" + row.enterpriseNo;
      }
      if (row.enterpriseNo >= 1000) {
        row.enterpriseNo = "GYS" + row.enterpriseNo;
      }
      return number;
    },

    handleManagerSelect(dict) {
      if (this.queryParams.supplierType === dict.value) {
        this.queryParams.supplierType = null; // 再次点击取消选择
      } else {
        this.queryParams.supplierType = dict.value;
      }
      this.handleQuery(); // 触发搜索
    },

    //pdf预览
    handlePictureCardPreviewPdf(url) {
      this.pdfUrl = pdf.createLoadingTask(url);
      // 获取页码
      this.pdfUrl.promise
        .then(pdf => (this.pageTotal = pdf.numPages))
        .catch(error => {});
      this.dialogImageUrlPdf = url;
      this.dialogVisiblePdf = true;
    },
    listType() {
      listType({ typeCode: "enterprise" }).then(res => {
        this.optionData = res.data;
      });
    },
    guId() {
      function S4() {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
      }

      return (
        S4() +
        S4() +
        "-" +
        S4() +
        "-" +
        S4() +
        "-" +
        S4() +
        "-" +
        S4() +
        S4() +
        S4()
      );
    },

    indexMethod(index) {
      return (
        (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1
      );
    },
    indexMethodDept(index) {
      return (
        (this.queryParamsDept.pageNum - 1) * this.queryParamsDept.pageSize +
        index +
        1
      );
    },
    indexLog(index) {
      return (
        (this.queryParamsLog.pageNum - 1) * this.queryParamsLog.pageSize +
        index +
        1
      );
    },
    indexLogDetail(index) {
      return (
        (this.queryParamsLogDetail.pageNum - 1) *
          this.queryParamsLogDetail.pageSize +
        index +
        1
      );
    },
    /** 查询企业信息列表 */
    getList() {
      this.loading = true;
      this.queryParams.belongTo = this.$store.state.user.info.orgId;
      // 直接构造日期范围参数，不使用 addDateRange
      const params = {
        ...this.queryParams,
      };
      // 如果有日期范围，则添加到参数中，并确保使用正确的日期格式
      if (this.dateRange && this.dateRange.length === 2) {
        // 使用 parseTime 或其他日期格式化方法来确保日期格式正确
        params.startTime = this.parseTime(this.dateRange[0], "{y}-{m}-{d}");
        params.finishTime = this.parseTime(this.dateRange[1], "{y}-{m}-{d}");
      }
      listInfo(params).then(response => {
        this.infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    cancelClass() {
      this.openMainClass = false;
      this.resetClass();
    },
    // 表单重置
    resetClass() {
      this.formClass = {
        classificationId: null,
      };
    },
    // 取消按钮
    cancel() {
      this.$emit("change");
    },
    submitForm() {
      if (this.selectionList.length === 0) {
        this.$modal.msgError("请选择客户！");
      }
      if (this.train === false) {
        this.$emit("ok", this.selectionList[0]);
      } else {
        this.$emit("ok", this.selectionList);
      }
      this.$refs.table.clearSelection();
    },

    //索引初始化到对象
    tableRowClassName({ row, rowIndex }) {
      //把每一行的索引放进row
      row.index =
        (this.queryParams.pageNum - 1) * this.queryParams.pageSize +
        rowIndex +
        1;
    },
    // 表单重置
    reset() {
      this.form = {
        enterpriseId: null,
        enterpriseName: null,
        enterpriseSource: null,
        enterpriseAbbreviation: null,
        administrativeArea: null,
        legalRepresentative: null,
        establishmentDate: null,
        contractAmount: null,
        enterpriseLabel: null,
        position: null,
        registeredCapital: null,
        industry: null,
        industryType: null,
        contacts: null,
        telephone: null,
        bankName: null,
        taxId: null,
        developmentId: null,
        transactionId: null,
        developmentManager: null,
        businessManager: null,
        enterpriseAddress: null,
        businessScope: null,
        enterpriseNature: null,
        markAs: null,
        belongTo: null,
        creationTime: null,
        operateTime: null,
        operateId: null,
        departmentId: null,
        departmentName: null,
        organizationId: null,
        organizationName: null,
        delFlag: null,
        classificationId: null,
      };
      this.resetForm("form");
    },
    editMainClass() {
      if (this.ids.length === 0) {
        this.$message.error("请选择要修改的信息！");
      } else {
        this.openMainClass = true;
      }
    },
    userShow(type) {
      this.show = type;
      if (type == "1") {
        if (this.ids.length === 0) {
          this.$message.error("请选择要修改的信息！");
        } else {
          this.$refs.select.show();
        }
      } else {
        this.$refs.select.show();
      }
    },
    submitClassForm() {
      if (
        this.formClass.classificationId === "undefined" ||
        this.formClass.classificationId === "" ||
        this.formClass.classificationId == null
      ) {
        this.$message.error("请选择主分类！");
      } else {
        const params = {
          businessId: this.ids.toString(),
          mainClassId: this.formClass.classificationId,
        };
        editMainClass(params).then(response => {
          this.$modal.msgSuccess("修改成功");
          this.openMainClass = false;
          this.getList();
        });
      }
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.industryType = null;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      if (this.markAs != null && this.train !== true) {
        this.selectionList = [];
        if (selection.length > 1) {
          this.$refs.table.clearSelection();
          this.$refs.table.toggleRowSelection(selection[selection.length - 1]);
        }
        this.selectionList = [selection[selection.length - 1]];
      } else {
        this.selectionList = selection;
      }
      this.ids = selection.map(item => item.enterpriseId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    handleAdd() {
      this.reset();
      this.id = this.guId();
      if (this.id!= null){
        this.edit = "add";
        this.type = 1;
      }

    },
    /** 修改按钮操作 */
    handleUpdate(row, index) {
      this.reset();
      this.tabId = row.enterpriseOrgId;
      this.index = row.enterpriseName;
      this.initiationId = row.enterpriseOrgId;
      this.receiverId = this.$store.state.user.info.orgId;
      this.supplierId = row.enterpriseOrgId;
      this.id = row.enterpriseId;
      this.enterpriseName = row.enterpriseName;
      if (this.id==row.enterpriseId){
        this.edit = "edit";
        this.type = 1;
      }
    },
    handleViewEnterprise(row, index){
      this.reset();
      this.tabId = row.enterpriseOrgId;
      this.index = row.enterpriseName;
      this.edit = "details";
      this.initiationId = row.enterpriseOrgId;
      this.receiverId = this.$store.state.user.info.orgId;
      this.supplierId = row.enterpriseOrgId;
      this.id = row.enterpriseId;
      this.enterpriseName = row.enterpriseName;
      this.type = 1;
    },
    //相关产品
    handleLvli(row) {},
    //树点击事件
    getNode(data, node, obj) {
      this.reset();
      //主分类

      //this.queryParams.cabinetId = data.id
      this.classId = data.id;
      this.queryParams.classificationId = data.id;
      this.getList();
    },

    /** 下载模板操作 */
    importTemplate() {
      this.download(
        "/enterprise/info/importTemplate",
        {},
        this.titleName + `.xlsx`
      );
    },
    close: function (data) {
      if (data == undefined) {
        this.type = 0;
        this.open = data;
      }
      this.getList();
    },
    //文件预览
    handleView(url) {
      if (url != null && url != "" && url.indexOf(".pdf") !== -1) {
        this.handlePictureCardPreviewPdf(url);
      } else {
        this.handlePictureCardPreview(url);
      }
    },
    handlePictureCardPreview(url) {
      this.dialogImageUrl = url;
      this.dialogVisible = true;
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.enterpriseId || this.ids;
      this.$modal
        .confirm(
          '是否确认删除名称为"' + row.enterpriseName + '"的供应商数据项？'
        )
        .then(function () {
          return delInfo(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
  },
};
</script>
<style scoped>
.manager-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;

  .manager-tag {
    padding: 0 12px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;

    &:hover {
      border-color: #409eff;
      color: #409eff;
    }

    &.active {
      background-color: #409eff;
      border-color: #409eff;
      color: #fff;
    }
  }
}
</style>
